package com.gjy.spring.controller;

import com.gjy.spring.entity.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.time.LocalDateTime;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-02-06 14:14:10
 */
@RestController
@RequestMapping("/reactor")
public class ReactorController {

    @GetMapping("/mono")
    public Mono<String> getMono() {
        return Mono.just("Hello, Mono!");
    }

    @GetMapping("/flux")
    public Flux<String> getFlux() {
        return Flux.just("Hello", "Flux!");
    }

    @GetMapping("/aj")
    public Flux<AjaxResult> getAj() {
        return Flux.just(AjaxResult.builder().code("200").message("OK").data(LocalDateTime.now()).build());
    }

    @GetMapping("/aj2")
    public Mono<AjaxResult> getAj2() {
        return Mono.just(AjaxResult.builder().code("200").message("OK").data(LocalDateTime.now()).build());
    }

}
